package com.kexilo.dict.domain;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 字典数据抽象模型
 * 不依赖任何具体的字典实体，完全解耦
 * 
 * @author Kexilo
 */
public class DictData implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 字典编码
     */
    private Long dictCode;
    
    /**
     * 字典排序
     */
    private Integer dictSort;
    
    /**
     * 字典标签
     */
    private String dictLabel;
    
    /**
     * 字典键值
     */
    private String dictValue;
    
    /**
     * 字典类型
     */
    private String dictType;
    
    /**
     * 样式属性（其他样式扩展）
     */
    private String cssClass;
    
    /**
     * 表格字典样式
     */
    private String listClass;
    
    /**
     * 是否默认（Y是 N否）
     */
    private String isDefault;
    
    /**
     * 状态（0停用 1正常）
     */
    private String status;
    
    /**
     * 备注
     */
    private String remark;
    
    /**
     * 创建者
     */
    private String createBy;
    
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    
    /**
     * 更新者
     */
    private String updateBy;
    
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    
    // 构造器
    public DictData() {}
    
    public DictData(String dictLabel, String dictValue, String dictType) {
        this.dictLabel = dictLabel;
        this.dictValue = dictValue;
        this.dictType = dictType;
    }
    
    // Builder模式构造器
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder {
        private DictData dictData = new DictData();
        
        public Builder dictCode(Long dictCode) {
            dictData.dictCode = dictCode;
            return this;
        }
        
        public Builder dictSort(Integer dictSort) {
            dictData.dictSort = dictSort;
            return this;
        }
        
        public Builder dictLabel(String dictLabel) {
            dictData.dictLabel = dictLabel;
            return this;
        }
        
        public Builder dictValue(String dictValue) {
            dictData.dictValue = dictValue;
            return this;
        }
        
        public Builder dictType(String dictType) {
            dictData.dictType = dictType;
            return this;
        }
        
        public Builder cssClass(String cssClass) {
            dictData.cssClass = cssClass;
            return this;
        }
        
        public Builder listClass(String listClass) {
            dictData.listClass = listClass;
            return this;
        }
        
        public Builder isDefault(String isDefault) {
            dictData.isDefault = isDefault;
            return this;
        }
        
        public Builder status(String status) {
            dictData.status = status;
            return this;
        }
        
        public Builder remark(String remark) {
            dictData.remark = remark;
            return this;
        }
        
        public Builder createBy(String createBy) {
            dictData.createBy = createBy;
            return this;
        }
        
        public Builder createTime(LocalDateTime createTime) {
            dictData.createTime = createTime;
            return this;
        }
        
        public Builder updateBy(String updateBy) {
            dictData.updateBy = updateBy;
            return this;
        }
        
        public Builder updateTime(LocalDateTime updateTime) {
            dictData.updateTime = updateTime;
            return this;
        }
        
        public DictData build() {
            return dictData;
        }
    }
    
    // Getters and Setters
    public Long getDictCode() { return dictCode; }
    public void setDictCode(Long dictCode) { this.dictCode = dictCode; }
    
    public Integer getDictSort() { return dictSort; }
    public void setDictSort(Integer dictSort) { this.dictSort = dictSort; }
    
    public String getDictLabel() { return dictLabel; }
    public void setDictLabel(String dictLabel) { this.dictLabel = dictLabel; }
    
    public String getDictValue() { return dictValue; }
    public void setDictValue(String dictValue) { this.dictValue = dictValue; }
    
    public String getDictType() { return dictType; }
    public void setDictType(String dictType) { this.dictType = dictType; }
    
    public String getCssClass() { return cssClass; }
    public void setCssClass(String cssClass) { this.cssClass = cssClass; }
    
    public String getListClass() { return listClass; }
    public void setListClass(String listClass) { this.listClass = listClass; }
    
    public String getIsDefault() { return isDefault; }
    public void setIsDefault(String isDefault) { this.isDefault = isDefault; }
    
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    
    public String getRemark() { return remark; }
    public void setRemark(String remark) { this.remark = remark; }
    
    public String getCreateBy() { return createBy; }
    public void setCreateBy(String createBy) { this.createBy = createBy; }
    
    public LocalDateTime getCreateTime() { return createTime; }
    public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
    
    public String getUpdateBy() { return updateBy; }
    public void setUpdateBy(String updateBy) { this.updateBy = updateBy; }
    
    public LocalDateTime getUpdateTime() { return updateTime; }
    public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
    
    /**
     * 是否启用状态
     */
    public boolean isEnabled() {
        return "1".equals(this.status);
    }
    
    /**
     * 是否默认选项
     */
    public boolean isDefaultOption() {
        return "Y".equals(this.isDefault);
    }
    
    @Override
    public String toString() {
        return "DictData{" +
                "dictCode=" + dictCode +
                ", dictSort=" + dictSort +
                ", dictLabel='" + dictLabel + '\'' +
                ", dictValue='" + dictValue + '\'' +
                ", dictType='" + dictType + '\'' +
                ", status='" + status + '\'' +
                '}';
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        DictData dictData = (DictData) obj;
        return dictCode != null ? dictCode.equals(dictData.dictCode) : 
               (dictValue != null && dictType != null && 
                dictValue.equals(dictData.dictValue) && dictType.equals(dictData.dictType));
    }
    
    @Override
    public int hashCode() {
        return dictCode != null ? dictCode.hashCode() : 
               (dictValue != null && dictType != null ? 
                (dictValue + dictType).hashCode() : super.hashCode());
    }
}
